package com.seecen.myspringboot.controller;

import com.seecen.myspringboot.entity.Book;
import com.seecen.myspringboot.service.BookService;
import com.seecen.myspringboot.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/book")
public class BookController {

    @Resource(name = "bookServiceImpl")
    @Autowired
    @Qualifier("bookServiceImpl")
    private BookService bookService;

    @PostMapping("/save")
    public Result<Book> save(@RequestBody Book book) {
        bookService.save(book);
        return Result.success(book);
    }
}
